import service from './index.js'

export const getCaptchaApi = () => {
	return service.post('/base/captcha')
}

export const loginApi = (params) => {
	return service.post('/base/login', params)
}

export const getMenuApi = () => {
	return service.post('/menu/getMenu')
}

export const getUserInfoApi = () => {
	return service.get('/user/getUserInfo')
}

export const getBaseMenuTreeApi = () => {
	return service.post('/menu/getBaseMenuTree')
}

export const getMenuAuthorityApi = (params) => {
	return service.post('/menu/getMenuAuthority', params)
}

export const addMenuAuthorityApi = (params) => {
	return service.post('/menu/addMenuAuthority', params)
}

export const getRolesListApi = () => {
	return service.post('/authority/getAuthorityList', { page: 1, pageSize: 999 })
}

export const resetPasswordApi = (params) => {
	return service.post('/user/resetPassword', params)
}

export const setUserInfoApi = (params) => {
	return service.put('/user/setSelfInfo', params)
}

export const changePwdApi = (params) => {
	return service.post('/user/changePassword', params)
}

export const getArticleByIdApi = (id) => {
	return service.get('/blog/getArticleById?ID=' + id)
}

export const updateArticleApi = (params) => {
	return service.put('/blog/updateArticle', params)
}

export const createArticleApi = (params) => {
	return service.post('/blog/createArticle', params)
}

export const getTimeArticleListApi = () => {
	return service.get('/blog/getTimeArticleList')
}

export const uploadApi = (file) => {
	let formData = new FormData()
	formData.append('file', file.file)
	return service.post('/fileUploadAndDownload/upload', formData, {
		headers: {
			'Content-Type': 'multipart/form-data',
		},
	})
}
